$("#bindAll").on(
		"click",
		function() {
			var val = $("#search1").val();

			// 根据查询条件查询的所有未绑定用户[未分页信息]
			var typeId = $("#typeId").val();
			$.ajax({
				url : rootPath + "/ui/userEventTypeBind/findAllUnbind/"
						+ typeId,
				type : 'get',
				data : {
					"con" : val
				},
				dataType : 'json',
				success : function(result) {
					var typeIds = typeId + ",";
					var users = result.data.users;
					var userIds = '';
					$.each(users, function() {
						userIds += this.id + ",";
					});
					$.ajax({
						url : rootPath + '/ui/userEventTypeBind/bind/'
								+ userIds + "/" + typeIds,
						dataType : 'json',
						type : 'get',
						success : function(result) {
							if (result.code == 1) {
								alert(result.data.msg);
								$("#progressbar").hide();
								reloadPage2();
							}
						}
					});

				}
			});
		});

// ===============================================================
$("#unbindAll").on(
		"click",
		function() {
			var val = $("#search2").val();

			// 根据查询条件查询的所有绑定用户[未分页信息]
			var typeId = $("#typeId").val();
			$.ajax({
				url : rootPath + "/ui/userEventTypeBind/findAllBind/" + typeId,
				type : 'get',
				data : {
					"con" : val
				},
				dataType : 'json',
				success : function(result) {
					var typeIds = typeId + ",";
					var users = result.data.users;
					var userIds = '';
					$.each(users, function() {
						userIds += this.id + ",";
					});
					$.ajax({
						url : rootPath + '/ui/userEventTypeBind/unbind/'
								+ userIds + "/" + typeIds,
						dataType : 'json',
						type : 'get',
						success : function(result) {
							if (result.code == 1) {
								alert(result.data.msg);
								$("#progressbar").hide();
								reloadPage2();
							}
						}
					});

				}
			});
		});
// =============================================
function reloadPage2() {
	$("#selectAllBind").prop("checked", false);
	$("#selectAllUnbind").prop("checked", false);
	bindUserData.key = $("#typeId").val();
	// bindUserData.con = '';
	bindUserTable.draw();
	unbindUserData.key = $("#typeId").val();
	// unbindUserData.con = '';
	unbindUserTable.draw();
	var treeObj = $.fn.zTree.getZTreeObj("eventTree");
	treeObj.checkAllNodes(false);
}
